<?php
function addToSList($id){
		$slist = new Shoplist(con());
		$test = $slist->getName($id);
		if (count($test) == 0){
			$slist->add($id);
		}
		$result = $slist->getAll();
		return  $result;
}

function getList(){
		$slist = new Shoplist(con());
		$result = $slist->getAll();
		return  $result;
}

function removeFromList($id){
		$slist = new Shoplist(con());
		$slist->remove($id);
		$result = $slist->getAll();
		return  $result;
}

function mailList($htmlContent){
	$headers = 'From: РъНъТъ@PyNyTy.com' . "\r\n";
	$headers.= 'MIME-Version: 1.0' . "\r\n";
	$headers.= 'Content-type: text/html; charset=UTF-8' . "\r\n";
	mail($_SESSION['user_mail'], "покупки", stripcslashes($htmlContent), $headers);
	return $_SESSION['user_mail'];
}


function mailGroupList($htmlContent){
	$headers = 'From: РъНъТъ@PyNyTy.com' . "\r\n";
	$headers.= 'MIME-Version: 1.0' . "\r\n";
	$headers.= 'Content-type: text/html; charset=UTF-8' . "\r\n";
	$users = new Groups(con());
	$mailList = $users->getGroupUsers($_SESSION['group_id']);
	$recepients = array();
	foreach ($mailList as $userMail){
		mail($userMail[0], "покупки", stripcslashes($htmlContent), $headers);
		array_push($recepients, $userMail[1]); 
	}
	return $recepients;
}



function clearList(){
		$slist = new Shoplist(con());
		$slist->removeAll();
		$result = $slist->getAll();
		return  $result;
}


?>